﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace Brjnk.GpxExplorer.UI
{
    /// <summary>
    /// Interaction logic for QuestionWindow.xaml
    /// </summary>
    public partial class QuestionWindow : Window
    {
        private Question question;
        private IEnumerable<Answer> answers;

        public QuestionWindow(Question question, IEnumerable<Answer> answers)
        {
            InitializeComponent();
            this.question = question;
            this.answers = answers;
            this.Loaded += new RoutedEventHandler(QuestionWindow_Loaded);
        }

        private void QuestionWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.questionTxbl.DataContext = question;
            this.answersIc.DataContext = answers;
        }

        private void ButtonClicked(object sender, RoutedEventArgs e)
        {
            this.result = ((e.Source as Button).DataContext as Answer).ID;
            this.DialogResult = true;
        }

        private object result;

        public object Result
        {
            get { return result; }
        }
    }
}